home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-02-09 | 1.2 KB | 46 lines | [TEXT/GEOL] |
- Item 0672165 7-Feb-90 10:43PST
-
- From: WBJ Judd, William B
-
- To: CPLUS.APPLE$ C++ Interest List--Apple Employees
- CPLUS.DEV$ C++ Interest List--Developers
-
- Sub: Novice Asks A Question
-
- So far I have been unable to get the following program from "C++ For C
- Programmers" by Ira Pohl, page 11, to work. The variable "miles" in the "cin
- <<" statement never gets the right value, and execution never pauses at that
- statement after the first execution of it.
-
- Can anyone tell me what the problem is?
-
- Thanks,
-
- Bill Judd, WBJ
- PSAP I/O Software
-
- P.S. I just asked to be added to the CPlus.Apple$ group, but I might not be on
- the list yet, so please post your answer to the lists & link me directly at my
- AppleLink address (WBJ). Thanks.
-
- //miles are converted to kilometers
-
- #include <stream.h>
- const float m_to_k = 1.609;
- inline int convert(int mi) { return (mi * m_to_k);}
-
- main()
- {
- int miles;
-
- do {
- cout << "Input distance in miles: ";
- cin >> miles;
- cout << "\nDistance is " << convert(miles) << " km. \n";
- } while (miles > 0);
- }
-
- // end of program
-
-
-